<template>
  <div id="app-container" style="padding:30px;">
    <el-form label-width="130px">
      <el-form-item label="批次:">
        <el-dropdown @command="handleCommand">
          <span class="el-dropdown-link">
             请选择<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-input v-model="bookLists.batchId"/>
          </el-dropdown-menu>
        </el-dropdown>
      </el-form-item>
      <el-form-item label="书单名称">
        <el-col :span="5">
          <el-input v-model="bookLists.name"/>
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button :disabled="saveBtnDisabled" type="primary" @click="saveBookList()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import bookList from "@/api/copyrightin/bookList/bookList";

  export default {
    data() {
      return {
        bookLists: {},
        saveBtnDisabled: false, // ##不禁用保存按钮
        BASE_API: process.env.VUE_APP_BASE_API
      }
    },
    methods: {
      saveBookList() {
        this.saveBtnDisabled = true // ##禁用保存按钮
        bookList.saveBookList(this.bookLists)
          .then(response => {
            // ## 提示信息
            this.$message({
              type: 'success',
              message: '添加成功!'
            })
            // ## 回到list页面,重定向功能
            this.$router.push('/bms/copyright/bookList/list')
          })
      }
    }
  }
</script>
